#!/usr/bin/python3
import jinja2

# 创建一个env对象，指定模板的加载方式为文件系统
env = jinja2.Environment(loader=jinja2.FileSystemLoader('./templates'))

# 加载一个模板文件，这个文件的内容是一个HTML页面，其中有一些占位符
template = env.get_template('template.html')

desktops = [
    {
        'name': "Kylin-Desktop-V10-SP1-General-Release-2303-X86_64.iso",
        'md5': "5126ef298073fd809e45a2e509217b55 ",
        'url': "https://distro-images.kylinos.cn:8802/web_pungi/download/share/StiBZ6nrblo2xHpXJuEIO5PVaQsgd0Nw/Kylin-Desktop-V10-SP1-General-Release-2303-X86_64.iso",
        'baidu': "https://pan.baidu.com/s/1Prj9-OrNalMjNr_6KrvTRQ?pwd=1234",
        'xunlei': "magnet:?xt=urn:btih:A3IZ4PLCIX33JOCRR6AHVGTT76KNUWNA&dn=Kylin-Desktop-V10-SP1-General-Release-2303-X86_64.iso&tr=http%3A%2F%2Fwx.kylinos.cn%3A46969%2Fannounce&tr=udp%3A%2F%2Fwx.kylinos.cn%3A46969%2Fannounce&xl=4004306944"
    },
    {
        'name': "银河麒麟桌面操作系统V10 SP1 HWE X86-2303 Intel/AMD",
        'url': "https://distro-images.kylinos.cn:8802/web_pungi/download/share/wovH7FnLp1CqAGOSrY4QbhXy9If62Uzs/Kylin-Desktop-V10-SP1-HWE-Release-2303-X86_64.iso",
        'md5': "7ec9ca842e901ed57f5c9cf317f9ff97 "
    }
]

# 定义一些数据，这些数据会替换模板中的占位符
data = {
    'desktops': desktops
}

# 调用模板的render方法，传入数据，得到最终的文档
document = template.render(data)

# 打印或保存文档
print(document)
with open("report.html", 'w', encoding='utf-8') as f:
    f.write(document)